package route

import (
	"fmt"
	"ifashion/admin/dal"
	"ifashion/admin/model"

	"github.com/kataras/iris"
	"github.com/kataras/iris/context"
)

type rec struct {
}

func (m rec) Save(ctx context.Context) {
	var op model.Cloth
	ctx.ReadJSON(&op)
	fmt.Println("test3")
	fmt.Println(op)
	rt := dal.Rec.Save(op)
	ctx.StatusCode(iris.StatusOK)
	ctx.JSON(map[string]interface{}{"success": rt == "success", "rt": rt})
}
func (m rec) Lst(ctx context.Context) {
	var op model.Num
	ctx.ReadJSON(&op)
	fmt.Println("test")
	fmt.Println(op)
	ds, total, rt := dal.Rec.Lst(op)
	fmt.Println(ds)
	ctx.StatusCode(iris.StatusOK)
	ctx.JSON(map[string]interface{}{"success": rt == "success", "ds": ds, "total": total})
}

// func (m rec) Lst(ctx context.Context) {
// 	var op model.Num
// 	ctx.ReadJSON(&op)
// 	ds, total, rt := dal.Rec.Lst(op)
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "ds": ds, "total": total})
// }
func (m rec) Del(ctx context.Context) {
	var op model.Ops
	ctx.ReadJSON(&op)
	rt := dal.Rec.Del(op.Ids)
	ctx.StatusCode(iris.StatusOK)
	ctx.JSON(map[string]interface{}{"success": rt == "success", "rt": rt})
}

//分割线
// func (m rec) SSave(ctx context.Context) {
// 	var op model.SRec
// 	ctx.ReadJSON(&op)
// 	rt := dal.Rec.SSave(op)
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "rt": rt})
// }

//备注
// func (m rec) HotSqry(ctx context.Context) {
// 	var op model.SRec
// 	ctx.ReadJSON(&op)
// 	ds, rt := dal.Rec.HotAnalyze(op)
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "ds": ds})
// }

// func (m rec) SLst(ctx context.Context) {
// 	//todo 传主表参数,完成
// 	var op model.Op
// 	ctx.ReadJSON(&op)
// 	ds, total, rt := dal.Rec.SLst(op.BM)
// 	println(total)
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "ds": ds, "total": total})
// }
// func (m rec) SDel(ctx context.Context) {
// 	var op model.Ops
// 	ctx.ReadJSON(&op)
// 	rt := dal.Rec.SDel(op.Ids)
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "rt": rt})
// }
// func (m rec) SQry(ctx context.Context) {
// 	ds, total, rt := dal.Rec.QrySLst()
// 	ctx.StatusCode(iris.StatusOK)
// 	ctx.JSON(map[string]interface{}{"success": rt == "success", "ds": ds, "total": total})
// }
